package com.ncp.servlet.bbs;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ncp.model.biz.bbs.ArticleProcess;
import com.ncp.model.biz.bbs.ReplyProcess;
import com.ncp.model.entity.comment.Articlebean;
import com.ncp.model.entity.comment.Replybean;

public class ShowReplyServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html");
		int nowPage=1;
		String now=request.getParameter("nowPage");
		if(now!=null){
			nowPage=Integer.parseInt(now);
		}
		int id=Integer.parseInt(request.getParameter("id"));
		ArticleProcess ap=new ArticleProcess();
		ReplyProcess rp=new ReplyProcess();
		int PageCount=rp.getCount(id);
		ArrayList<Replybean> rlist=rp.getRepaly(id,nowPage);
		Articlebean ab=ap.showArticleDetail(id);
		ap.addClick(id);
		request.setAttribute("rlist",rlist);
		request.setAttribute("ab", ab);
		request.setAttribute("nowPage", nowPage+"");
		request.setAttribute("pageCount", PageCount+"");
		request.getRequestDispatcher("pages/bbs/showreply.jsp").forward(request, response);
	}


	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		this.doGet(request, response);
	}

}
